package lq;

import java.util.Scanner;

public class lq2017 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        for (int i=0;i<n;i++){
            String zfc=in.next();
            char[] s = zfc.toCharArray();
            int count=0;
            for (int j=0;j<zfc.length();j++){
                int b = s[j];
                if (b>47&&b<58){
                    count++;
                }
            }
            System.out.println(count);
        }

    }
}
